package parser

import (
	"engine"
	"regexp"
	"model"
)

var datetimeRe = regexp.MustCompile(`<div id="info">[\s\S]+时间:</span>([^<]+)</div>`)

func ParseNews(contents []byte, url string,title string) engine.ParseResult {
	match := datetimeRe.FindSubmatch(contents)
	news := model.News{}
	if match != nil {
		news.Datetime = string(match[1])
		news.Title = title
		news.Url = url
		//fmt.Printf("新闻标题：%s [%s], 链接：%s", news.Title,news.Datetime, news.Url)
		//fmt.Println()
	}

	return engine.ParseResult{
		Items: []interface{}{news},
	}
}